package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	Mysql
	Redis
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

type Redis struct {
	Host     string
	Port     int
	Password string
}

var Config AppConfig

func Init() {
	viper.SetConfigFile("appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(fmt.Errorf("viper初始化配置出错：Fatal error config file: %s \n", err))
	}
	viper.Unmarshal(&Config)
	log.Println(Config)
}
